package com.code.generate;

import java.io.File;

public class MyFile extends File {
	private static final long serialVersionUID = 1L;
	private String encoding;

	public MyFile(File f) {
		super(f.getAbsolutePath());
		if (f.isFile()) {
			String enc = null;
			// 暂时不采用读取编码的方式
			// enc = FileOperator.getEncode(f);
			if (enc == null) {
				if (f.getName().endsWith(".java")) {
					enc = "UTF-8";
				} else if (f.getName().endsWith(".jsp")) {
					enc = "UTF-8";
				} else if (f.getName().endsWith(".ftl")) {
					enc = "UTF-8";
				} else {
					enc = "UTF-8";
				}
			}
			this.encoding = enc;
		}
	}

	@Override
	public String toString() {
		return this.getName();
	}

	public String getEncoding() {
		return encoding;
	}

	public void setEncoding(String encoding) {
		this.encoding = encoding;
	}
}
